package alibaba.ifelserefactor.demo01.test03;

import alibaba.ifelserefactor.demo01.ShareListener;
import alibaba.ifelserefactor.demo01.ShareType;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author ChangLiang
 * @date 2020/4/20
 */
@Data
@AllArgsConstructor
public abstract class ShareItem {
    public ShareType type;

    public abstract void doShare(ShareListener listener);

    /**
     * 或者有人会说，这样用户也需额外了解多几个方法。
     * 我个人觉得让用户了解多几个方法好过了解多几个类，而已方法名一看就能知道意图，成本还是挺小，是可以接受的。
     *
     */

    public static ShareItem createLinkShareItem(ShareType type, String title, String content) {
        Link link = new Link(type, title, content);
        return link;
    }

    public static ShareItem createImageShareItem(ShareType type) {
        return new Image(type);
    }

    public static ShareItem createTextShareItem(ShareType type) {
        return new Text(type);
    }

    public static ShareItem createImageTextShareItem(ShareType type) {
        return new ImageText(type);
    }
}
